.class Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;
.super Ljava/lang/Object;

# interfaces
.implements Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;->produceResults(Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Ljava/lang/Object;",
        "Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer<",
        "Lcom/kwad/sdk/api/loader/Api$Data;",
        ">;"
    }
.end annotation


# instance fields
.field final synthetic this$0:Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;

.field final synthetic val$consumer:Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;


# direct methods
.method constructor <init>(Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;)V
    .locals 0

    iput-object p1, p0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->this$0:Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;

    iput-object p2, p0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->val$consumer:Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


# virtual methods
.method public onFailure(Ljava/lang/Throwable;)V
    .locals 1

    iget-object v0, p0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->val$consumer:Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;

    invoke-interface {v0, p1}, Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;->onFailure(Ljava/lang/Throwable;)V

    return-void
.end method

.method public onNewResult(Lcom/kwad/sdk/api/loader/Api$Data;)V
    .locals 3

    :try_start_0
    iget-object v0, p0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->this$0:Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;

    iget-object v1, p0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->this$0:Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;

    iget-object v1, v1, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;->mContext:Landroid/content/Context;

    invoke-static {v0, v1}, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;->access$000(Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;Landroid/content/Context;)Z

    move-result v0

    if-eqz v0, :cond_1

    iget-object v0, p0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->this$0:Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;

    iget-object v0, v0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;->mContext:Landroid/content/Context;

    iget-object v1, p1, Lcom/kwad/sdk/api/loader/Api$Data;->downloadFile:Ljava/io/File;

    invoke-virtual {v1}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v1

    iget-object v2, p1, Lcom/kwad/sdk/api/loader/Api$Data;->sdkVersion:Ljava/lang/String;

    invoke-static {v0, v1, v2}, Lcom/kwad/sdk/api/loader/ApkInstaller;->installApk(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->this$0:Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;

    iget-object v0, v0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer;->mContext:Landroid/content/Context;

    sget-object v1, Lcom/kwad/sdk/api/loader/DVersionUtils;->NEWVERSION:Ljava/lang/String;

    iget-object v2, p1, Lcom/kwad/sdk/api/loader/Api$Data;->sdkVersion:Ljava/lang/String;

    invoke-static {v0, v1, v2}, Lcom/kwad/sdk/api/loader/DVersionUtils;->setVersion(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V

    iget-object v0, p0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->val$consumer:Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;

    const/4 v1, 0x1

    invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v1

    invoke-interface {v0, v1}, Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;->onNewResult(Ljava/lang/Object;)V

    iget-object p1, p1, Lcom/kwad/sdk/api/loader/Api$Data;->downloadFile:Ljava/io/File;

    invoke-static {p1}, Lcom/kwad/sdk/api/loader/Dir;->deleteFile(Ljava/io/File;)V

    return-void

    :cond_0
    new-instance p1, Ljava/lang/RuntimeException;

    const-string v0, "Apk pre install failed"

    invoke-direct {p1, v0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw p1

    :cond_1
    iget-object p1, p0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->val$consumer:Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;

    new-instance v0, Ljava/lang/RuntimeException;

    const-string v1, "not main process"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    invoke-interface {p1, v0}, Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;->onFailure(Ljava/lang/Throwable;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception p1

    iget-object v0, p0, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->val$consumer:Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;

    invoke-interface {v0, p1}, Lcom/kwad/sdk/api/loader/ProducerFactory$Consumer;->onFailure(Ljava/lang/Throwable;)V

    :goto_0
    return-void
.end method

.method public bridge synthetic onNewResult(Ljava/lang/Object;)V
    .locals 0

    check-cast p1, Lcom/kwad/sdk/api/loader/Api$Data;

    invoke-virtual {p0, p1}, Lcom/kwad/sdk/api/loader/ProducerFactory$InstallProducer$1;->onNewResult(Lcom/kwad/sdk/api/loader/Api$Data;)V

    return-void
.end method
